<!--Copyright (C) Kherty.  All rights reserved.-->
<oui:GroupPanel
    x:Class="OpenLS.Spreadsheet.UI.PageLayoutTabContent"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:oui="http://schemas.Kherty.com/office/2007"
    xmlns:ssui="clr-namespace:OpenLS.Spreadsheet.UI"
    xmlns:drawing="http://schemas.Kherty.com/office/2007/drawing"
    xmlns:Internals="clr-namespace:OpenLS.Spreadsheet.UI.Internals"
    xmlns:Spreadsheet="clr-namespace:OpenLS.Spreadsheet;assembly=OpenLS.Spreadsheet"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:media="clr-namespace:OpenLS.Media;assembly=OpenLS.Media"
    xmlns:Core="clr-namespace:OpenLS.Core;assembly=OpenLS.Core"
    xmlns:Internals1="clr-namespace:OpenLS.Drawing.UI.Internals;assembly=OpenLS.Drawing.UI"
    xmlns:Internals2="clr-namespace:OpenLS.UI.Internals;assembly=OpenLS.UI"
    xmlns:Resources="clr-namespace:OpenLS.Spreadsheet.UI.Internals.Resources"
    TextElement.Foreground="{DynamicResource {x:Static oui:OfficeBrushes.TextForegroundKey}}">
    <oui:GroupPanel.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <drawing:DrawingResources/>
                <ssui:PageMarginsResources></ssui:PageMarginsResources>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </oui:GroupPanel.Resources>


    <oui:Group Header="{x:Static Resources:UIStringTable.Themes}" SnapsToDevicePixels="True">
        <Menu>
            <MenuItem Header="{x:Static Resources:UIStringTable.Themes}" oui:RibbonElement.ControlState="Large" ItemsSource="{x:Static drawing:BuiltInThemes.Instances}" oui:HighlightElement.HighlightedItemChanged="OnThemePreviewChanged" >
                <oui:RibbonElement.Icon>
                    <ContentControl Content="{Binding Path=Theme}" ContentTemplate="{x:Static Internals1:DrawingTemplates.SmallThemeTemplate}">
                        <ContentControl.LayoutTransform>
                            <ScaleTransform ScaleX="0.6666666666666666" ScaleY="0.6666666666666666"/>
                        </ContentControl.LayoutTransform>
                    </ContentControl>
                </oui:RibbonElement.Icon>
                <MenuItem.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel MaxWidth ="450"/>
                    </ItemsPanelTemplate>
                </MenuItem.ItemsPanel>
                <MenuItem.ItemContainerStyle>
                    <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
                        <Setter Property ="Command" Value="{x:Static drawing:ThemeCommands.SetTheme}"/>
                        <Setter Property ="CommandParameter" Value="{Binding}"/>
                    </Style>
                </MenuItem.ItemContainerStyle>
            </MenuItem>

            <!-- </Menu> -->
            <MenuItem oui:RibbonElement.ControlState="Medium" ItemsSource="{x:Static drawing:BuiltInThemes.ColorSchemes}" oui:HighlightElement.HighlightedItemChanged="OnColorPreviewChanged" >
                <MenuItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <ContentControl Content="{Binding Path=Theme.ColorScheme}"
                                  ContentTemplate ="{x:Static Internals1:DrawingTemplates.SmallColorScheme}"/>
                        <TextBlock Text="{x:Static Internals2:UIStringTable.Colors}"></TextBlock>
                    </StackPanel>
                </MenuItem.Header>
                <MenuItem.ItemContainerStyle>
                    <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
                        <Setter Property ="Command" Value="{x:Static drawing:ThemeCommands.SetColorScheme}"/>
                        <Setter Property ="CommandParameter" Value="{Binding}"/>
                    </Style>
                </MenuItem.ItemContainerStyle>
            </MenuItem>
            <MenuItem oui:RibbonElement.ControlState="Medium"
                        ItemsSource="{x:Static drawing:BuiltInThemes.FontSchemes}" oui:HighlightElement.HighlightedItemChanged="OnFontSchemePreviewChanged" >
                <MenuItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <Border BorderThickness="1" BorderBrush="Black">
                            <Viewbox Height="16" Width="16">
                                <ContentControl Content="{Binding Path=Theme.FontScheme}" ContentTemplate="{x:Static Internals1:DrawingTemplates.SmallFontScheme}"/>
                            </Viewbox>
                        </Border>
                        <TextBlock Text="{x:Static Internals2:UIStringTable.Fonts}"></TextBlock>
                    </StackPanel>
                </MenuItem.Header>
                <MenuItem.ItemContainerStyle>
                    <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
                        <Setter Property ="Command" Value="{x:Static drawing:ThemeCommands.SetFontScheme}"/>
                        <Setter Property ="CommandParameter" Value="{Binding}"/>
                    </Style>
                </MenuItem.ItemContainerStyle>

            </MenuItem>
        </Menu>
        <!--</StackPanel>
          </StackPanel> -->
    </oui:Group>
    <oui:Group Header="{x:Static Resources:UIStringTable.PageSetup}">
        <Menu>
            <Menu.Resources>
                <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}" x:Key="autoHideMenuItem">
                    <Style.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Menu.Resources>
            <MenuItem Header="{x:Static Resources:UIStringTable.Margins}" oui:RibbonElement.Icon="{media:Image MarginGallery}"
                      ItemsSource="{x:Static Internals:PaperHelper.PageMargins}">
                
                <MenuItem.ItemContainerStyle>
                    <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
                        <Setter Property="Command" Value="{x:Static oui:ViewCommands.SetPageMargin}"/>
                        <Setter Property="CommandParameter" Value="{Binding}"/>
                    </Style>
                </MenuItem.ItemContainerStyle>
            </MenuItem>
            <MenuItem Header="{x:Static Resources:UIStringTable.Size}" oui:RibbonElement.Icon="{media:Image PageSize}"
                              ItemsSource="{x:Static Internals:PaperHelper.PageSizes}"
                              ItemTemplate="{x:Static  Internals1:DrawingTemplates.PaperSizeTemplate}">
                <MenuItem.ItemContainerStyle>
                    <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
                        <Setter Property="Command" Value="{x:Static oui:ViewCommands.SetPaperSize}"/>
                        <Setter Property="CommandParameter" Value="{Binding}"/>
                    </Style>
                </MenuItem.ItemContainerStyle>
            </MenuItem>
            <MenuItem Header="{x:Static Internals2:UIStringTable.Orientation}" oui:RibbonElement.Icon="{media:Image PageOrientationPortraitLandscape}">
                <MenuItem Command="{x:Static oui:ViewCommands.SetOrientation}" Header="{x:Static Internals2:UIStringTable.Portrait}" CommandParameter="{x:Static Core:Orientation.Portrait}"  oui:RibbonElement.Icon="{media:Image PageOrientationPortrait}" />
                <MenuItem Command="{x:Static oui:ViewCommands.SetOrientation}" Header="{x:Static Internals2:UIStringTable.Landscape}" CommandParameter="{x:Static Core:Orientation.Landscape}"  oui:RibbonElement.Icon="{media:Image PageOrientationLandscape}" />
            </MenuItem>
            <MenuItem Header="{x:Static Resources:UIStringTable.PrintArea}" oui:RibbonElement.Icon="{media:Image PrintArea}">
                <MenuItem Command="{x:Static ssui:SpreadsheetCommands.SetPrintArea}" />
                <MenuItem Command="{x:Static ssui:SpreadsheetCommands.ClearPrintArea}"/>
            </MenuItem>
            <MenuItem Command="{x:Static ssui:SpreadsheetEditingCommands.SetBackgroundPicture}" Header="{x:Static Resources:UIStringTable.Background}" Style="{StaticResource autoHideMenuItem}" Icon="{media:Image SheetBackground}" />
            <MenuItem Command="{x:Static ssui:SpreadsheetEditingCommands.DeleteBackgroundPicture}" Header="{x:Static Resources:UIStringTable.DeleteBackground}"  Style="{StaticResource autoHideMenuItem}" Icon="{media:Image SheetBackground}" />
        </Menu>
    </oui:Group>
    <oui:Group Header="{x:Static Resources:UIStringTable.ScaleToFit}">
        <oui:Group.Resources>
            <Style TargetType="{x:Type Label}" x:Key="labelWithColon">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Label}">
                            <StackPanel Orientation="Horizontal">
                                <Label Margin="1" Padding="0" Foreground="{DynamicResource {x:Static oui:OfficeBrushes.TextForegroundKey}}"
                                           VerticalAlignment="Center"  VerticalContentAlignment="Center" Content="{TemplateBinding Content}" />
                                <Label Margin="1" Padding="0" Foreground="{DynamicResource {x:Static oui:OfficeBrushes.TextForegroundKey}}"
                                           VerticalAlignment="Center"  VerticalContentAlignment="Center" Content=":" />
                            </StackPanel>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="Foreground" Value="{DynamicResource {x:Static oui:OfficeBrushes.TextForegroundKey}}"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
            </Style>
            <DataTemplate DataType="{x:Type System:Int32}">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding}" Name="number"/>
                    <TextBlock Text=" "/>
                    <TextBlock Text="{x:Static Resources:UIStringTable.Pages}" Name="pages"></TextBlock>
                </StackPanel>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding }" Value="0">
                        <Setter TargetName="number" Property="Visibility"  Value="Collapsed"/>
                        <Setter TargetName="pages" Property="Text"  Value="{x:Static Resources:UIStringTable.Automatic}"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding }" Value="1">
                        <Setter TargetName="pages" Property="Text"  Value="{x:Static Resources:UIStringTable.Page}"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
        </oui:Group.Resources>
        <UniformGrid Rows="3">
            <DockPanel >
                <ComboBox Margin="0"  DockPanel.Dock="Right" MinWidth="90" SelectedIndex="{Binding RelativeSource={RelativeSource Self}, Path=(ssui:SpreadsheetElement.Worksheet).PageSetup.FitToWidth}">
                    <System:Int32>0</System:Int32>
                    <System:Int32>1</System:Int32>
                    <System:Int32>2</System:Int32>
                    <System:Int32>3</System:Int32>
                    <System:Int32>4</System:Int32>
                    <System:Int32>5</System:Int32>
                    <System:Int32>6</System:Int32>
                    <System:Int32>7</System:Int32>
                    <System:Int32>8</System:Int32>
                    <System:Int32>9</System:Int32>
                </ComboBox>
                <Label Content="{x:Static Resources:UIStringTable.Width}" Style="{StaticResource labelWithColon}" />
            </DockPanel>
            <DockPanel >
                <ComboBox Margin="0" DockPanel.Dock="Right" MinWidth="90" SelectedIndex="{Binding RelativeSource={RelativeSource Self}, Path=(ssui:SpreadsheetElement.Worksheet).PageSetup.FitToHeight}">
                    <System:Int32>0</System:Int32>
                    <System:Int32>1</System:Int32>
                    <System:Int32>2</System:Int32>
                    <System:Int32>3</System:Int32>
                    <System:Int32>4</System:Int32>
                    <System:Int32>5</System:Int32>
                    <System:Int32>6</System:Int32>
                    <System:Int32>7</System:Int32>
                    <System:Int32>8</System:Int32>
                    <System:Int32>9</System:Int32>
                </ComboBox>
                <Label Content="{x:Static Resources:UIStringTable.Height}" Style="{StaticResource labelWithColon}"/>

            </DockPanel>
            <DockPanel >
                <oui:NumericUpDown DockPanel.Dock="Right"  Maximum="400"  Minimum="10" SmallChange="5"  MinWidth="90"
                                           Value="{Binding RelativeSource={RelativeSource Self}, Path=(ssui:SpreadsheetElement.Worksheet).PageSetup.Scale}"/>
                <Label Content="{x:Static Resources:UIStringTable.Scale}" Style="{StaticResource labelWithColon}"/>
            </DockPanel>
        </UniformGrid>
    </oui:Group>
    <oui:Group Header="{x:Static Resources:UIStringTable.SheetOptions}" DataContext="{Binding RelativeSource={RelativeSource Self}, Path=(ssui:SpreadsheetElement.Worksheet)}">
        <StackPanel Orientation="Horizontal">
            <StackPanel Orientation="Vertical">
                <TextBlock Text="{x:Static Resources:UIStringTable.Gridlines}"></TextBlock>
                <CheckBox IsChecked="{Binding Path=View.GridLinesVisible, Mode=TwoWay}" Content="{x:Static Resources:UIStringTable.View}"></CheckBox>
                <CheckBox IsChecked="{Binding Path=PrintOptions.GridLinesVisible, Mode=TwoWay}" Content="{x:Static Resources:UIStringTable.Print}"></CheckBox>
            </StackPanel>
            <StackPanel Orientation="Vertical">
                <TextBlock  Text="{x:Static Resources:UIStringTable.Headings}"></TextBlock>
                <CheckBox IsChecked="{Binding Path=View.RowColumnHeadersVisible, Mode=TwoWay}" Content="{x:Static Resources:UIStringTable.View}"></CheckBox>
                <CheckBox IsChecked="{Binding Path=PrintOptions.RowColumnHeadersVisible, Mode=TwoWay}"  Content="{x:Static Resources:UIStringTable.Print}"></CheckBox>
            </StackPanel>
        </StackPanel>
    </oui:Group>
  <!--
    <oui:Group Header="{x:Static Internals2:UIStringTable.Arrange}">
        <StackPanel Orientation="Horizontal">
            <Menu>
                <MenuItem Header='{x:Static Internals:UIStringTable.BringToFront}' Icon='{media:Image ObjectBringToFront}'>
                    <MenuItem Command ='{x:Static ssui:SpreadsheetCommands.BringToFront}' oui:RibbonElement.ControlState="Medium" CommandParameter="{Binding}"/>
                    <MenuItem Command ='{x:Static ssui:SpreadsheetCommands.BringForward}' oui:RibbonElement.ControlState="Medium" CommandParameter="{Binding}"/>
                </MenuItem>
            </Menu>
            <Menu>
                <MenuItem Header="{x:Static Internals:UIStringTable.SendToBack}" Icon="{media:Image ObjectSendToBack}">
                    <MenuItem Command ='{x:Static ssui:SpreadsheetCommands.SendToBack}' oui:RibbonElement.ControlState="Medium"  CommandParameter="{Binding}"/>
                    <MenuItem Command ='{x:Static ssui:SpreadsheetCommands.SendBackward}' oui:RibbonElement.ControlState="Medium"  CommandParameter="{Binding}"/>
                </MenuItem>
            </Menu>
        </StackPanel>
    </oui:Group>
    -->
</oui:GroupPanel>
